package com.component.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.component.domain.MNoteVersion;
import com.component.service.MNoteVersionService;
import com.component.mapper.MNoteVersionMapper;
import com.system.common.Result;
import com.system.security.SecurityUtil;
import com.system.security.domain.SelfUserEntity;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 *
 */
@Service
public class MNoteVersionServiceImpl extends ServiceImpl<MNoteVersionMapper, MNoteVersion>
    implements MNoteVersionService{

    @Override
    public JSONObject addMNoteVersion(String nid, String title, String channelId, String content) {
        SelfUserEntity userEntity=SecurityUtil.getSelfUserEntity();
        MNoteVersion mnoteVersion = new MNoteVersion();
        mnoteVersion.setChannelId(channelId);
        mnoteVersion.setContent(content);
        mnoteVersion.setNoteTitle(title);
        mnoteVersion.setNoteId(nid);
        if(userEntity!=null){
            mnoteVersion.setOperateUid(userEntity.getUserId().toString());
        }
        mnoteVersion.setCreatedate(new Date());
        super.save(mnoteVersion);
        return Result.successInfo("新增成功");
    }
}




